HackerRank Chief Hopper
解答
code: python
import math
import os
import random
import re
import sys
#
# Complete the 'chiefHopper' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER_ARRAY arr as parameter.
#
# newenergy = 2*botenergy - height
# energy = (energy + height + 1) // 2
#
# 4 6 1
# 2 4 3
# 3 <- answer
# 1 6 4
# 5 4 4
def chiefHopper(arr):
# Write your code here
energy = 0
energy = (energy + height + 1) // 2
return energy
if __name__ == '__main__':
n = int(input().strip())
arr = list(map(int, input().rstrip().split()))
result = chiefHopper(arr)
fptr.write(str(result) + '\n')
fptr.close()
メモ
https://www.youtube.com/watch?v=x4kNidSmPpo